using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using ZoneFiveSoftware.Common.Data.Fitness;

namespace MatrixPlugin
{
   public partial class TableChartViewer : UserControl
   {
      private ActivityDetailChartWithBannerModified chart;
      private readonly Form _form = null;

      public TableChartViewer()
      {
         Init();
      }

      public TableChartViewer(IList<IActivity> activities, bool includeLocationAndDate, bool showDialog)
      {
         Init();

         if (showDialog) // ??
         {
            _form = new Form();
            _form.Controls.Add(this);
            _form.Size = new Size(800, 600); //Settings.WindowSize;
            //form.Icon = Icon.FromHandle(Resources.Image_32_HighScore.GetHicon());
            base.Parent.SizeChanged += new EventHandler(SizeChanged_handler);
            _form.StartPosition = FormStartPosition.CenterScreen;
            //progressBar.Size = new Size(base.Size.Width - 20, progressBar.Height);
            _form.Show();
         }
         else
         {
            base.SizeChanged += new EventHandler(SizeChanged_handler);
         }

         Activities = activities;
      }

      public void Init()
      {
         InitializeComponent();

         // Add detailed chart run-time
         //chart = new ActivityDetailChartWithBannerModified();
         //splitContainer1.Panel2.Controls.Add(chart);
         //chart.Dock = System.Windows.Forms.DockStyle.Fill;
         //chart.Location = new System.Drawing.Point(0, 0);
      }

      public IList<IActivity> Activities
      {
         set
         {
            chart.SetActivity(value[0]);
            tableViewer1.Activities = value;
         }
      }

      private void SizeChanged_handler(object sender, EventArgs e)
      {
         //setSize();
      }

      public void ThemeChanged(ZoneFiveSoftware.Common.Visuals.ITheme visualTheme)
      {
      }

      public void UICultureChanged(CultureInfo culture)
      {
         Refresh();
      }
   }
}